package com.mud.mudcommune.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.facebook.drawee.view.SimpleDraweeView;
import com.mud.mudcommune.R;

import java.util.List;

/**
 * Created by zhoujin on 2016/12/11.
 */

public class DesignWorkAdapter extends RecyclerView.Adapter<DesignWorkAdapter.ViewHolder> {
    private final Context mContext;
    private LayoutInflater mInflater;
    private List list;

    public DesignWorkAdapter(Context context, @NonNull List list) {
        this.mContext = context;
        this.mInflater = LayoutInflater.from(context);
        this.list = list;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = mInflater.inflate(R.layout.work_design_item, parent, false);
        ViewHolder mViewHolder = new ViewHolder(view);
        return mViewHolder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.designImg.setImageResource(R.mipmap.test13);
        // java.lang.OutOfMemoryError  内存溢出解决方案
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
        SimpleDraweeView designImg;

        public ViewHolder(View view) {
            super(view);
            designImg = (SimpleDraweeView) view.findViewById(R.id.design_img);
            designImg.setOnClickListener(this);
        }

        @Override
        public void onClick(View view) {
            switch (view.getId()) {
//                case R.id.design_img:
//                    ((AppCompatActivity) mContext).getSupportFragmentManager().beginTransaction()
//                            .hide(ChiefDetailsFragment.getInstance())
//                            .add(R.id.main_frame, CaseDetailsFragment.getInstance())
//                            .addToBackStack(null)
//                            .commit();
//                    break;
            }
        }
    }


}
